<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
	
<%
	request.setCharacterEncoding("UTF-8");
	String htmlData = request.getParameter("content1") != null ? request.getParameter("content1") : "";
%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ include file="/WEB-INF/JSP/backHome/modalWindows/argeeCommon.jsp" %>
<%@ include file="/WEB-INF/JSP/backHome/modalWindows/againstAuditCommon.jsp" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="<%=path%>/My97DatePicker/WdatePicker.js"></script>
<link rel="stylesheet" type="text/css" href="<%=path%>/CSS/backLayout.css">
<link rel="stylesheet" type="text/css" href="<%=path%>/CSS/bombBox.css">
</head>
<style>
select{width: 234px;height: 31px}
.gn_name{padding-top: 5px}
.div_zilei{padding-left: 90px;height: 30px}
.tr{height:40px;background: #57a0ff;font-weight:700;}
.tr td{font-size: 14px;color: #ffffff}
.tr_td{height: 40px;}
.tr_td td{border-bottom: 1px solid #ededed;text-align: center;}
tr td:nth-child(1) {font-size: 14px;color: #cccccc}
.date{border: 0;background: #ffffff;text-align: center;}
.tr_td td:nth-child(1){border-left: 1px solid #cccccc;}
.tr_td td:nth-child(3){border-right: 1px solid #cccccc;}
.addTable.deleteTable:HOVER{cursor:pointer;}
input[type='checkbox']{width: 15px}
.fseq2{border: none;color: #cccccc;text-align: center;}
			
</style>
<body style="background: #f5f5f5">
<div class="main">
<div id="modal-overlay">
			    
		</div>
		
		<div class="weizhi">
			<c:if test="${fillingWareReg.cfbillstate eq 3}">
				车辆管理>>加油入库登记>>修改
			</c:if>
			<c:if test="${fillingWareReg.cfbillstate eq 4 || fillingWareReg.cfbillstate eq 5}">
				车辆管理>>加油入库登记>>查看
			</c:if>
		</div>
<div class="modal-data1">
			<div style="height: 60px">
				<ul>
					<li
						style="text-align: left; margin-left: 60px; height: 40px; line-height: 40px">
						<span>名称：</span> <span> <input class="name1" type="text">
					</span> <span>
							<button class="findBtn1">查询</button>
					</span>
					</li>
				</ul>
			</div>
			<div style="width: 1100px; height: 350px; overflow: scroll;">
				<form action="">
					<table class="head1"
						style="width: auto; white-space: nowrap; border-spacing: 0px">
						<tr style="background: #f2f2f2; height: 30px; line-height: 20px;"
							class="sel">
							<td style="width: 20px"></td>
							<td width="100px">名称</td>
							<td width="100px">编码</td>
							<td width="100px">简称</td>
							<td width="100px">描述</td>
							<td width="150px">创建时间</td>
							<td width="100px">用户名</td>
							<td width="150px">最后修改时间</td>
							<td width="100px">用户名</td>
						</tr>
						<c:forEach items="${oilspecs}" var="s">
						<tr style="margin-top: 45px" class="oilspec">
						<td><input type="checkbox" class="check1" value="${s.fid}" name="oilspec" /></td>
							<td>${s.fnameL2}</td>
							<td>${s.fnumber}</td>
							<td>${s.fsimplename}</td>
							<td>${s.fdescriptionL2}</td>
							<td>${s.fcreatetime}</td>
							<td>${s.createName}</td>
							<td>${s.flastupdatetime}</td>
							<td>${s.updateName}</td>
						</tr>
						</c:forEach>
					</table>
				</form>
			</div>
			<button class="subtn1"
				style="width: 200px; position: absolute; bottom: 25px; font-size: 16px; left: 170px">
				确定</button>
			<button class="btn"
				style="width: 200px; position: absolute; bottom: 25px; font-size: 16px; right: 170px">
				关闭</button>
			</div>									
	<div class="div_body" style="box-shadow: 0 0 5px #cccccc;height: 950px">
	<c:if test="${fillingWareReg.cfbillstate eq 3}">
			<div class="div_form">		
				<form action="<%=path%>/DrivingSys/updateFillingWareReg" class="form" id="update_fillingWareReg" onsubmit="return subForm()">
					<input type="hidden" name="fid" value="${fillingWareReg.fid}">
						<div class="div_input_hang">
							<div class="input_hang">
								<span class="gn_name">驾校&nbsp;:&nbsp;</span>
								<input  type="text" name="name"  value="${department.fnameL2}" readonly="readonly" style="color: gray;"/>
							</div>
							<div class="input_hang">
								<span class="gn_name">单据编号&nbsp;:&nbsp;</span>
								<input  type="text" id="fnumber" name="fnumber" value="${fillingWareReg.fnumber}" style="color: gray;" readonly="readonly"/>
							</div>
							<div class="input_hang">
								<span class="gn_name">业务日期&nbsp;:&nbsp;</span>
								<input  type="text" name="fbizdate"  id="ywrq" value="${fillingWareReg.fbizdate}" 
								onclick="WdatePicker({el:'ywrq',dateFmt:'yyyy-MM-dd'})"/>
								<img onclick="WdatePicker({el:'ywrq',dateFmt:'yyyy-MM-dd'})" 
					            src="<%=path%>/image/date.jpg"  align="absmiddle" style="padding-left: 15px">
							</div>
						</div>
						<div class="div_input_hang">
							<div class="input_hang">
								<span class="gn_name">参考信息&nbsp;:&nbsp;</span>
								<input name="fdescription" value="${fillingWareReg.fdescription}"/>								
							</div>							
							<div class="input_hang">
								<span class="gn_name">单据状态&nbsp;:&nbsp;</span>
								<select name="cfbillstate" >
									<option id="shenhe" style="color: gray;" value="3">保存</option>
								</select>
							</div>							
					</div>
					
					<div class="div_zilei">
							<div style="width: 75%;text-align: right;">
								<img src="<%=path%>/image/insert2323.jpg" class="addTable">
								<span style="padding-right: 20px;color: #57a0ff;font-weight:700;font-size: 14px" class="addTable">添加</span>
								<img src="<%=path%>/image/delete212.png" class="deleteTable">
								<span class="deleteTable" style="color: #57a0ff;font-weight:700;font-size: 14px;" class="deleteTable">删除</span>
							</div>
					</div>
					<input type="hidden" class="stu">
					<div style="min-height: 500px;width: 75%;padding-left: 90px;">
					<div style="overflow:scroll;height: 500px;width: 100%"> 
							<table  width="100%" align="center" id="table1" style="min-height:50px;border-spacing:0;">
									<tr class="tr">
										<td  width="20px"><%--<input type="checkbox" name="" class="check">--%></td>
										<td  width="40px">序号</td>
										<td align="center">规格</td>
										<td align="center">油量(公升)</td>
										<td align="center">单价</td>
										<td align="center">金额</td>
										<td align="center">备注</td>										
									</tr>
									<c:forEach items="${fillingWareReg.fillingWareRegEntryList}" var="fillingWareRegEntry">
										<tr style="margin-top: 45px" class="">
										<td align="right" width="40px"><input type="checkbox" name="check2" style="width:15px" value=""></td>
    									<td><input type="text" name="fseq" class="fseq" value="${fillingWareRegEntry.fseq }"  readonly unselectable="on" style="width:40px;border:none;color:#cccccc;text-align: center;"></td>
    									<td><input type="text" name="oilName" value="${fillingWareRegEntry.cfoilspecName }" class="is_click_ne" onclick="changeoil2($(this))"><input type="hidden" name="oilId" value="${fillingWareRegEntry.cfoilspecid }"></td>
    									<td><input type="text" name="cfqty" value="${fillingWareRegEntry.cfnums }" class="cfqty"  onblur="countCfqty($(this))"><input type="hidden" value=""></td><td><input type="text" name="cfprice" value="${fillingWareRegEntry.cfprice }" class="cfprice" onblur="countCfamount($(this))"><input type="hidden" value=""></td>
    									<td><input type="text" name="cfamount" value="${fillingWareRegEntry.cfamount }" class="cfamount" readonly="readonly"><input type="hidden" value=""></td><td><input type="text" name="cfdesc" value="${fillingWareRegEntry.cfremark}"></td></tr>
									</c:forEach>
							</table>						
						</div>
					</div>
					
					
					 <div class="div_input_hang" style="margin-top: 50px">
							<div class="input_hang">
								<span class="gn_name">审核人&nbsp;:&nbsp;</span>
								<input name="fhandlerid" readonly="readonly" style="color: gray;" type="text" />
							</div>
							<div class="input_hang">
								<span class="gn_name">创建者&nbsp;:&nbsp;</span>
								<input name="createName" readonly readonly="readonly" value="${fillingWareReg.createName}" style="color: gray;" type="text"/>
							</div>
							<div class="input_hang">
								<span class="gn_name">创建时间&nbsp;:&nbsp;</span>
								<input name="fcreatetime" style="color: gray;" readonly="readonly" type="text" value="${fillingWareReg.fcreatetime}"/>
							</div> 
					</div> 
					
					<div class="div_tj" style="padding-top: 0px">
						<shiro:hasPermission name="/sureFillingWareReg">
							<div>
                                <input class="input_submit bc" value="" type="submit">
							</div>
						</shiro:hasPermission>

						<shiro:hasPermission name="/submitFillingWareReg">
							<div>
								<input type="button" class="input_submit tj" value=""  onclick="audit(4)"/>
							</div>
						</shiro:hasPermission>
						<div>
							<input type="button" class="input_submit cklc" value="" onclick="lookActivitiImg('publicProcess',$('#fnumber').val())">
						</div>
						<div>
							<input type="button" class="input_back fh"  value="" onclick="back()"/>
						</div>
					</div>
				</form>							
			</div>
		</c:if>


		<c:if test="${fillingWareReg.cfbillstate eq 4}">
			<div class="div_form">
				<form action="<%=path%>/DrivingSys/updateFillingWareReg" class="form" id="update_fillingWareReg">
					<input type="hidden" name="fid" value="${fillingWareReg.fid}">
					<div class="div_input_hang">
						<div class="input_hang">
							<span class="gn_name">驾校&nbsp;:&nbsp;</span>
							<input  type="text" name="name"  value="${department.fnameL2}" readonly="readonly" style="color: gray;"/>
						</div>
						<div class="input_hang">
							<span class="gn_name">单据编号&nbsp;:&nbsp;</span>
							<input  type="text" id="fnumber" name="fnumber" value="${fillingWareReg.fnumber}" style="color: gray;" readonly="readonly"/>
						</div>
						<div class="input_hang">
							<span class="gn_name">业务日期&nbsp;:&nbsp;</span>
							<input  type="text" name="fbizdate"  id="ywrq" value="${fillingWareReg.fbizdate}"
									onclick="WdatePicker({el:'ywrq',dateFmt:'yyyy-MM-dd'})" readonly="readonly"/>
							<img onclick="WdatePicker({el:'ywrq',dateFmt:'yyyy-MM-dd'})"
								 src="<%=path%>/image/date.jpg"  align="absmiddle" style="padding-left: 15px">
						</div>
					</div>
					<div class="div_input_hang">
						<div class="input_hang">
							<span class="gn_name">参考信息&nbsp;:&nbsp;</span>
							<input name="fdescription" value="${fillingWareReg.fdescription}" readonly="readonly"/>
						</div>
						<div class="input_hang">
							<span class="gn_name">单据状态&nbsp;:&nbsp;</span>
							<select name="cfbillstate" >
								<option id="shenhe" style="color: gray;" value="4">提交</option>
							</select>
						</div>
					</div>

					<div class="div_zilei">
						<%--<div style="width: 75%;text-align: right;">
							<img src="<%=path%>/image/insert2323.jpg" class="addTable">
							<span style="padding-right: 20px;color: #a9bbe0;font-size: 14px" class="addTable">添加</span>
							<img src="<%=path%>/image/delete212.png" class="deleteTable">
							<span class="deleteTable" style="color: #a9bbe0;font-size: 14px;" class="deleteTable">删除</span>
						</div>--%>
					</div>
					<input type="hidden" class="stu">
					<div style="min-height: 500px;width: 75%;padding-left: 90px;">
						<div style="overflow:scroll;height: 500px;width: 100%">
							<table  width="100%" align="center" id="table1" style="min-height:50px;border-spacing:0;">
								<tr class="tr">
									<td  width="20px"><input type="checkbox" name="" class="check"></td>
									<td  width="40px">序号</td>
									<td align="center">规格</td>
									<td align="center">油量(公升)</td>
									<td align="center">单价</td>
									<td align="center">金额</td>
									<td align="center">备注</td>
								</tr>
								<c:forEach items="${fillingWareReg.fillingWareRegEntryList}" var="fillingWareRegEntry">
									<tr style="margin-top: 45px" class="">
										<td align="right" width="40px"><input type="checkbox" name="check2" style="width:15px" value=""></td>
										<td><input type="text" name="fseq" class="fseq" value="${fillingWareRegEntry.fseq }"  readonly unselectable="on" style="width:40px;border:none;color:#cccccc;text-align: center;"></td>
										<td><input type="text" name="oilName" value="${fillingWareRegEntry.cfoilspecName }"  readonly="readonly"/><input type="hidden" name="oilId" value="${fillingWareRegEntry.cfoilspecid }" readonly="readonly"/></td>
										<td><input type="text" name="cfqty" value="${fillingWareRegEntry.cfnums }" class="cfqty"  onblur="countCfqty($(this))" readonly="readonly"/><input type="hidden" value=""  readonly="readonly"/></td><td><input type="text" name="cfprice" value="${fillingWareRegEntry.cfprice }" class="cfprice" onblur="countCfamount($(this))" readonly="readonly"/><input type="hidden" value="" readonly="readonly"/></td>
										<td><input type="text" name="cfamount" value="${fillingWareRegEntry.cfamount }" class="cfamount" readonly="readonly"><input type="hidden" value=""  readonly="readonly"/></td><td><input type="text" name="cfdesc" value="${fillingWareRegEntry.cfremark}" readonly="readonly"/></td></tr>
								</c:forEach>
							</table>
						</div>
					</div>


					<div class="div_input_hang" style="margin-top: 50px">
						<div class="input_hang">
							<span class="gn_name">审核人&nbsp;:&nbsp;</span>
							<input name="fhandlerid" readonly="readonly" style="color: gray;" type="text" />
						</div>
						<div class="input_hang">
							<span class="gn_name">创建者&nbsp;:&nbsp;</span>
							<input name="createName" readonly readonly="readonly" value="${fillingWareReg.createName}" style="color: gray;" type="text"/>
						</div>
						<div class="input_hang">
							<span class="gn_name">创建时间&nbsp;:&nbsp;</span>
							<input name="fcreatetime" style="color: gray;" readonly="readonly" type="text" value="${fillingWareReg.fcreatetime}"/>
						</div>
					</div>

					<div class="div_tj" style="padding-top: 0px">
						<shiro:hasPermission name="/auditFillingWareReg">
							<div>
								<input type="button" class="input_submit sh" value=""  onclick="audit(5)"/>
							</div>
						</shiro:hasPermission>
						<shiro:hasPermission name="/againstAuditFillingWareReg">
							<div>
								<input  class="input_submit fsh" value="" type="button" onclick="audit(3)">
							</div>
						</shiro:hasPermission>
						<div>
							<input type="button" class="input_submit cklc" value="" onclick="lookActivitiImg('publicProcess',$('#fnumber').val())">
						</div>
						<div>
							<input type="button" class="input_back fh"  value="" onclick="back()"/>
						</div>
					</div>
				</form>
			</div>
		</c:if>
		
		<c:if test="${fillingWareReg.cfbillstate eq 5}">		
			<div class="div_form">		
				<form id="update_fillingWareReg" action="<%=path%>/DrivingSys/updateFillingWareReg" class="form" >
					<input type="hidden" name="fid" value="${fillingWareReg.fid}">
						<div class="div_input_hang">
							<div class="input_hang">
								<span class="gn_name">驾校&nbsp;:&nbsp;</span>
								<input  type="text" name="name"  value="${department.fnameL2}" readonly="readonly" style="color: gray;"/>
							</div>
							<div class="input_hang">
								<span class="gn_name">单据编号&nbsp;:&nbsp;</span>
								<input  type="text" id="fnumber" name="fnumber" value="${fillingWareReg.fnumber}" style="color: gray;" readonly="readonly" disabled="disabled"/>
							</div>
							<div class="input_hang">
								<span class="gn_name">业务日期&nbsp;:&nbsp;</span>
								<input  type="text" name="fbizdate"  disabled="disabled" id="ywrq" value="${fillingWareReg.fbizdate}" 
								onclick="WdatePicker({el:'ywrq',dateFmt:'yyyy-MM-dd'})"/>
								<img onclick="WdatePicker({el:'ywrq',dateFmt:'yyyy-MM-dd'})" 
					            src="<%=path%>/image/date.jpg"  align="absmiddle" style="padding-left: 15px">
							</div>
						</div>
						<div class="div_input_hang">
							<div class="input_hang">
								<span class="gn_name">参考信息&nbsp;:&nbsp;</span>
								<input name="fdescription" value="${fillingWareReg.fdescription}" disabled="disabled"/>								
							</div>							
							<div class="input_hang">
								<span class="gn_name">单据状态&nbsp;:&nbsp;</span>
								<select name="cfbillstate"  >
									<option id="shenhe" style="color: gray;" value="5">审核</option>
								</select>
							</div>							
					</div>
					
					<div class="div_zilei">
							<div style="width: 75%;text-align: right;">
								<%--<img src="<%=path%>/image/insert2323.jpg" class="addTable">
								<span style="padding-right: 20px;color: #a9bbe0;font-size: 14px" class="addTable">添加</span>
								<img src="<%=path%>/image/delete212.png" class="deleteTable">
								<span class="deleteTable" style="color: #a9bbe0;font-size: 14px;" class="deleteTable">删除</span>--%>
							</div>
					</div>
					<input type="hidden" class="stu">
					<div style="min-height: 500px;width: 75%;padding-left: 90px;">
					<div style="overflow:scroll;height: 500px;width: 100%"> 
							<table  width="100%" align="center" id="table1" style="min-height:50px;border-spacing:0;">
									<tr class="tr">
										<td  width="20px"><input type="checkbox" name="" class="check"></td>
										<td  width="40px">序号</td>
										<td align="center">规格</td>
										<td align="center">油量(公升)</td>
										<td align="center">单价</td>
										<td align="center">金额</td>
										<td align="center">备注</td>										
									</tr>
									<c:forEach items="${fillingWareReg.fillingWareRegEntryList}" var="fillingWareRegEntry">
										<tr style="margin-top: 45px" class="">
										<td align="right" width="40px"><input type="checkbox" name="check2" style="width:15px" value=""></td>
    									<td><input type="text" name="fseq" class="fseq" value="${fillingWareRegEntry.fseq }"  readonly unselectable="on" style="width:40px;border:none;color:#cccccc;text-align: center;"></td>
    									<td><input type="text" name="oilName" value="${fillingWareRegEntry.cfoilspecName }"  readonly="readonly"/><input type="hidden" name="oilId" value="${fillingWareRegEntry.cfoilspecid }" readonly="readonly"/></td>
    									<td><input type="text" name="cfqty" value="${fillingWareRegEntry.cfnums }" class="cfqty" readonly="readonly"/><input type="hidden" value="" readonly="readonly"/></td><td><input type="text" name="cfprice" value="${fillingWareRegEntry.cfprice }" class="cfprice" onblur="countCfamount($(this))" readonly="readonly"/><input type="hidden" value="" readonly="readonly"/></td>
    									<td><input type="text" name="cfamount" value="${fillingWareRegEntry.cfamount }" class="cfamount" readonly="readonly"><input type="hidden" value="" readonly="readonly"/></td><td><input type="text" name="cfdesc" value="${fillingWareRegEntry.cfremark}" readonly="readonly"/></td></tr>
									</c:forEach>
							</table>						
						</div>
					</div>
					
					
					 <div class="div_input_hang" style="margin-top: 50px">
							<div class="input_hang">
								<span class="gn_name">审核人&nbsp;:&nbsp;</span>
								<input name="fhandlerid" readonly="readonly"  value="${fillingWareReg.checkName}" style="color: gray;" type="text" disabled="disabled" />
							</div>
							<div class="input_hang">
								<span class="gn_name">创建者&nbsp;:&nbsp;</span>
								<input name="createName" readonly readonly="readonly" value="${fillingWareReg.createName}" style="color: gray;" type="text" disabled="disabled"/>
							</div>
							<div class="input_hang">
								<span class="gn_name">创建时间&nbsp;:&nbsp;</span>
								<input name="fcreatetime" style="color: gray;" readonly="readonly" type="text" value="${fillingWareReg.fcreatetime}" disabled="disabled"/>
							</div> 
					</div> 
					
					<div class="div_tj" style="padding-top: 0px">
						<shiro:hasPermission name="/againstAuditFillingWareReg">
							<div>
								<input type="button" class="input_submit fsh" value=""  onclick="audit(3)"/>
							</div>
						</shiro:hasPermission>
						<div>
							<input type="button" class="input_submit cklc" value="" onclick="lookActivitiImg('publicProcess',$('#fnumber').val())">
						</div>
						<div>
							<input type="button" class="input_back fh"  value="" onclick="back()"/>
						</div>
					</div>
				</form>							
			</div>
		</c:if>
		
	</div>
</div>
</body>
<script type="text/javascript" src="<%=path%>/JQuery/jquery-1.8.2.js"></script>
<%@ include file="/WEB-INF/JSP/ajax.jsp" %>
<script type="text/javascript" src="<%=path%>/HoganJS/handlebars-v4.0.11.js"></script>
<script type="text/javascript">
_this = null;//缓存改变油规格对象
//弹出油量模式框
$(".addTable").click(function(){
	_this = null;//清空缓存
	$('#modal-overlay').css('visibility', 'visible')
    $('.modal-data1').css('visibility', 'visible')
 	$('input:checkbox[name=oilspec]').removeAttr('checked');
})
//关闭油 模式框
$(".btn").click(function(){
	$('#modal-overlay').css('visibility', 'hidden')
    $('.modal-data1').css('visibility', 'hidden')
    $('.modal-data2').css('visibility', 'hidden')
    $('.modal-data9').css('visibility', 'hidden')
    $('.modal-data10').css('visibility', 'hidden')
 	$('input:checkbox[name=oilspec]').removeAttr('checked');
})
//由于和input:checkbox冲突，在选择一次
$(".head1 tr td input:checkbox[name=oilspec]").live('click',function(){
 if($(this).is(':checked')){
    	$(this).removeAttr("checked");
    }else{
    	$(this).attr("checked",":checked")
    }
})
//单击选中 油的信息
$(".head1 tr td").live('click',function(){
	if($(this).parent().find("input:checkbox[name=oilspec]").is(':checked')){
		$(this).parent().find("input:checkbox[name=oilspec]").removeAttr("checked");
	}else{
		$(this).parent().find("input:checkbox[name=oilspec]").attr("checked",":checked")
	}
})

//根据名称查询
$(".findBtn1").click(function(){
	var name = $(".name1").val();
	$.ajax({
		url:'<%=path%>/DrivingSys/queOilspecByName', 
	    type: "post",
	    data:{'name':name},
	    dataType:"json",
	    success:function(json){
	    	var str = '';
	    	for (var i = 0; i < json.length; i++) {
                str += '<tr style="margin-top: 45px;" class="oilspec"><td><input '
                str +='type="checkbox" name="oilspec" class="check1" value="'+json[i].fid+'"></td>'
				if (json[i].fnameL2 == null) {
					str += '<td></td>'
				} else {
					str += '<td>' + json[i].fnameL2 + '</td>'
				}
				if (json[i].fnumber == null) {
					str += '<td></td>'
				} else {
					str += '<td>' + json[i].fnumber + '</td>'
				}
				if (json[i].fsimplename == null) {
					str += '<td></td>'
				} else {
					str += '<td>' + json[i].fsimplename + '</td>'
				}
				if (json[i].fdescriptionL2 == null) {
					str += '<td></td>'
				} else {
					str += '<td>' + json[i].fdescriptionL2 + '</td>'
				}
				if (json[i].fcreatetime == null) {
					str += '<td></td>'
				} else {
					str += '<td>' + json[i].fcreatetime + '</td>'
				}
				if (json[i].createName == null) {
					str += '<td></td>'
				} else {
					str += '<td>' + json[i].createName + '</td>'
				}
				if (json[i].flastupdatetime == null) {
					str += '<td></td>'
				} else {
					str += '<td>' + json[i].flastupdatetime + '</td>'
				}
				if (json[i].updateName == null) {
					str += '<td></td>'
				} else {
					str += '<td>' + json[i].updateName + '</td>'
				}
	    	}
	    	$(".head1 tr:not(':first')").remove()
			$('.head1').append(str)
	    },  
			error: function(){alert('错误！！！');} 
	})
})

//修改油 弹出框
function changeoil2(obj){
	_this = obj;//记录需要修改的对象
	$('#modal-overlay').css('visibility', 'visible')   
    $('.modal-data1').css('visibility', 'visible')
 	$('input:checkbox[name=oilspec]').removeAttr('checked');
}

//确定把信息填入
$(".subtn1").click(function (){
	var oilName = new Array()//油的名称
	var oilId = new Array()//油的id
	$("input:checkbox[name=oilspec]:checked").each(function (i){
		oilId[i] = $(this).val();
		oilName[i] =$(this).parent().parent().find("td").eq("1").html();
	})	
	if( oilId.length == 0 || oilName.length == 0){
		alert("请勾选油卡！")
		return false;
	}
	if(_this != null){		
		_this.val(oilName[0]);
		_this.next().val(oilId[0])
		_this.parent().parent().find("td").eq("0").children("input:checkbox[name=check2]").val(oilId[0])
		_this.parent().next().children("input").val('')//把之前填入的值清空
		_this.parent().next().next().children("input").val('')//把之前填入的值清空
		_this.parent().next().next().next().children("input").val('')//把之前填入的值清空
        _this = null;//用完清空
	}else{	
		$('input:checkbox[name=oilspec]:checked').each(function(i) {
	    	oilName[i] = $(this).parent().parent().find("td").eq("1").html() 
	    	addTableTr(oilName[i],oilId[i])
	     });
		//处理序号
		$('input:text[name=fseq]').each(function(j){
			j+=1
			$(this).val(j)
		})
	}
	$('#modal-overlay').css('visibility', 'hidden')
    $('.modal-data1').css('visibility', 'hidden')
    $('.modal-data2').css('visibility', 'hidden')
 	$('input:checkbox[name=oilspec]').removeAttr('checked');
})

//双击确认
$(document).on('dblclick','.oilspec td',function(){	
	var oilId = '';//油卡id
	var oilName='';//油卡名称
	oilId = $(this).parent().find("td").eq("0").find("input:checkbox[name=oilspec]").val()
	oilName = $(this).parent().find("td").eq("1").html()
	//alert(oilId+" "+oilName)
	//addTableTr(oilName,oilId)
    if(_this != null){
        _this.val(oilName);
        _this.next().val(oilId)
        _this.parent().parent().find("td").eq("0").children("input:checkbox[name=check2]").val(oilId[0])
        _this.parent().next().children("input").val('')//把之前填入的值清空
        _this.parent().next().next().children("input").val('')//把之前填入的值清空
        _this.parent().next().next().next().children("input").val('')//把之前填入的值清空
        _this =null;//用完清空
    }else{
        addTableTr(oilName,oilId)
    }
	//处理序号
	$('input:text[name=fseq]').each(function(j){
		j+=1
		$(this).val(j)
	})
	$('#modal-overlay').css('visibility', 'hidden')
    $('.modal-data1').css('visibility', 'hidden')
    $('.modal-data2').css('visibility', 'hidden')
   	$('input:checkbox[name=oilspec]').removeAttr('checked');
})

//设置全选功选 
$('.check').click(function(){
	if($(this).attr("checked")){
		 $(":checkbox").prop("checked",true) 
	}else{
		$('input:checkbox').removeAttr('checked')
	}
})
//单击选中车辆信息
$("#table1 tr td").live('click',function(){
	if($(this).parent().find("input:checkbox[name=check2]").is(':checked')){
		$(this).parent().find("input:checkbox[name=check2]").removeAttr("checked");
	}else{
		$(this).parent().find("input:checkbox[name=check2]").attr("checked",":checked")
	}
})
//增加一行tr方法
function addTableTr(oilName,oilId){
	var str = '';
	str+='<tr style="margin-top: 45px" class="">'
	str+='<td align="right" width="40px"><input type="checkbox" name="check2" style="width:15px" value=""></td>'
    str+='<td><input type="text" name="fseq" class="fseq" value=""  readonly unselectable="on" style="width:40px;border:none;color:#cccccc;text-align: center;"></td>'
    str+='<td><input type="text" name="oilName" value="'+oilName+'" class="is_click_ne" onclick="changeoil2($(this))"><input type="hidden" name="oilId" value="'+oilId+'"></td>'
    str+='<td><input type="text" name="cfqty" value="" class="cfqty" onblur="countCfqty($(this))"><input type="hidden" value=""></td><td><input type="text" name="cfprice" value="" class="cfprice" onblur="countCfamount($(this))"><input type="hidden" value=""></td>'
    str+='<td><input type="text" name="cfamount" value="0" class="cfamount" readonly="readonly"><input type="hidden" value=""></td><td><input type="text" name="cfdesc" value=""></td></tr>'
    $("#table1").append(str);
}
//删除选中的行
$(".deleteTable").click(function (){
	var k=0;//记录被选中复选框的个数
	$("input:checked[name=check2]").each(function (i){
		k++;	
	})
	if(k == 0){
    	alert("请勾选中需要删除的行！")
    	return false;
	}else{
		$("input:checked[name=check2]").each(function (i){			
			$(this).parent().parent().remove();						
			//处理序号
			$('input:text[name=fseq]').each(function(j){
				j+=1
				$(this).val(j)
			})
		})
	}
})

//数量失去焦点计算金额
function countCfqty(obj){
	//避免最后一个字符串是.
 	obj.val((obj.val().replace(/\.$/g, "")));
    if(isNaN(Number(obj.val()))){
        obj.val("");
    }
 	var count = obj.val();//输入的数量
 	if(count == ''){
 		count = 0; 		
 	}
	//获取数量对应的单价
	var price = obj.parent().parent().find("td").eq("4").children("input:text[name=cfprice]").val();
	if( price == ''){
		price = 0;		
	}	
	count = count*1;//去除类是于 023 数据
	//price = decimal(price,2);
	var cfamount = price*count
	cfamount = decimal(cfamount,2);
	//填入总额
	obj.parent().parent().find("td").eq("5").children("input:text[name=cfamount]").val(cfamount)
}
//单价失去焦点计算金额
function countCfamount(obj){
	//避免最后一个字符串是.
 	obj.val((obj.val().replace(/\.$/g, "")));
    if(isNaN(Number(obj.val()))){
        obj.val("");
    }
 	var price = obj.val();//输入的单价
 	if(price == ''){
 		price = 0; 		
 	}
	//获取单价对应的数量
	var count = obj.parent().parent().find("td").eq("3").children("input:text[name=cfqty]").val();
	if( count == ''){
		count = 0;		
	}
	count = count*1;//去除类是于 023 数据
	//price = decimal(price,2);
	var cfamount = price*count
	cfamount = decimal(cfamount,2);
	//填入总额
	obj.parent().parent().find("td").eq("5").children("input:text[name=cfamount]").val(cfamount)					
}

//num是要处理的数字  v为要保留的小数位数
function decimal(num,v){
	var vv = Math.pow(10,v);
return Math.round(num*vv)/vv;
}

//键盘事件
$(".cfqty,.cfprice").live('keyup', function(event) {
		//最后一位是小数点的话，移除
		var $amountInput = $(this);
		//响应鼠标事件，允许左右方向键移动 
		event = window.event || event;
		if(event.keyCode == 37 | event.keyCode == 39) {
			return;
		}
		//先把非数字的都替换掉，除了数字和. 
		$amountInput.val($amountInput.val().replace(/[^\-?\d.]/g, "").
		//只允许一个小数点              
		replace(/^\./g, "").replace(/\.{2,}/g, ".").
		//只能输入小数点后两位
		replace(".", "$#$").replace(/\./g, "").replace("$#$", ".").replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'));
});
//返回
function back(){
    parent.closeSelectCard()

//    location = '<%=path%>/DrivingSys/queryFillingWareReg/look.action';
} 
//改变审核状态
function audit(num) {
    var fid = $("input:hidden[name=fid]").val();
    var fnumber =$("input:text[name=fnumber]").val();
    if(num == 3){//反审核
        $('#modal-overlay').css('visibility', 'visible');
        $('.modal-data10').css('visibility', 'visible');
        $("#againstAuditsubmit").click(function(){
            var againstAuditcomment = $("#againstAuditcomment").val();
            if (againstAuditcomment == null || againstAuditcomment == '') {
                againstAuditcomment = "不同意";
            }
            $.ajax({
                url:'<%=path%>/DrivingSys/againstCheckFillingWareRegActiviti',
                type:'post',
                data:{'fid':fid,'fnumber':fnumber,'againstAuditcomment':againstAuditcomment},
                dataType:'json',
                success:function(result){
                    if(result["result"] == 'success'){
                        showAlert("反审核成功!","queryFillingWareReg/look.action")
                        /*alert("反审核成功!")
                        setTimeout(function () {
                            location="<%=path%>/DrivingSys/queryFillingWareReg/look.action";
                        }, 1000);*/
                    }else{
                        alert("反审核失败!")
                    }
                },
                error:function () {alert('Error')}
            })
        })
    }
    if(num == 4){//提交
        $.messager.confirm('提示', '是否提交?', function (r) {
            if(r){
                $.ajax({
                    url:'<%=path%>/DrivingSys/submitFillingWareRegActiviti',
                    type:'post',
                    data:{'fid':fid,'fnumber':fnumber},
                    dataType:'json',
                    success:function(result){
                        if(result["result"] == 'success'){
                            showAlert("提交成功!","queryFillingWareReg/look.action")
                            /*alert("提交成功!")
                            setTimeout(function () {
                                location="<%=path%>/DrivingSys/queryFillingWareReg/look.action";
                            }, 1000);*/
                        }else{
                            alert("提交失败!")
                        }
                    },
                    error:function () {alert('Error')}
                })
			}
		})
    }
    if(num == 5){//审核
        $('#modal-overlay').css('visibility', 'visible');
        $('.modal-data9').css('visibility', 'visible');
        $("#auditsubmit").click(function() {
            var agree = $("input:radio[name=check]:checked").val();//同意不同意
            var auditcomment = $("#auditcomment").val();
            if (agree == null) {
                alert("你选择你的意见");
                return false;
            }
            if (auditcomment == null || auditcomment == '') {
                if(agree == "1"){
                    auditcomment = "同意";
                }else{
                    auditcomment = "不同意";
                }
            }
            $.ajax({
                url:'<%=path%>/DrivingSys/checkFillingWareRegActiviti',
                type:'post',
                data:{'fid':fid,'fnumber':fnumber,'agree':agree,'auditcomment':auditcomment},
                dataType:'json',
                // async: true,
                success:function(result){
                    if(result["result"] == 'success'){
                        showAlert("审核成功!","queryFillingWareReg/look.action")
                       /* alert("审核成功!")
                        setTimeout(function () {
                            location="<%=path%>/DrivingSys/queryFillingWareReg/look.action";
                        }, 1000);*/
                    }else{
                        alert("审核失败!")
                    }
                },
                error:function () {alert('Error')}
            })
        })
    }
}
//验证没有子数据不能保存
function subForm() {
    var count =0;
    $("input:checkbox[name=check2]").each(function (i) {
        count++;
    })
    if(count==0){
        alert("至少添加一种油耗!")
        return false;
    }
    $("input[type='submit']").attr("disabled", "disabled");
}
</script>
</html>